<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>材料申请审批</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../resources/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../resources/css/style.css" media="all">
    <style>
        .layui-form-label{width: 100px; height: 20px;}
        .layui-form-select{width: 190px;}
        #gonghuoshijian{ width: 100%;}
        .addUser input{width: 86%;}
        .layui-form-select{width: 100%!important;}
        .layui-form-select input{width: 100%;}
        .layui-form-item{padding-left: 70px;}
        .layui-form-item .layui-input-inline{width: 73%!important;}
        .masksx{width: 800px;}
        .material{display: flex;justify-content: flex-start;padding-left: 15px;padding-right: 77px;margin-bottom: 8px;width: 100%;margin-left: 55px;}
        .material label{float: left;height: 38px;line-height: 38px; display: inline-block;}
        ._mater{width: 49%;margin-left: 73px;}
        ._materwarp{width: 50%;}
        .material ._mater_input{width: 10%;}
        ._mater_lab{margin:0 20px;}
        .addTo{background-color: #86B1FC;color: #FFF; width: 10px;height: 10px;display: none}
        .materialone .addTo{display:inline;}
        .mater_btn{margin: 6px 0 0 6px;}
        .material_C{width: 100px;text-align: justify;}
        .material_C:after{content:'';width: 100%;display: inline-block;}
        .materialone .mater_btn{display: none;}
        .forms{padding-top: 20px;}
        .layui-form-selectup dl{top: -184px;}
        .layui-input-inlineon{width: 80%;}
        .saixuan:after{width: 0;}
        .huanhang{margin-top: 0;}
        @media only screen and (min-width: 321px) and (max-width: 1024px) {
            .chaxun{text-align: right;padding-right: 20px; margin-top: 10px;}
        }
        .chaxun{text-align: right;}
        @media only screen and (max-width: 1000px) {
            .huanhang{margin-top: 10px;}
        }

    </style>
</head>
<body>
<div class="_PC">
    <a class="dayin" type="button" id="dlink"  style="float: right; position: fixed; right: 50px; bottom: 50px; z-index: 999;"></a>
    <form class="layui-form layui-form-pane" id="form_7grid" action="" lay-filter="hetong">
        <div class="formTop">
            <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs4">
                <div class="layui-input-inlineon">
                    <input type="text" name="proName" lay-verify="required" placeholder="项目名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs4">
                <div class="layui-input-inlineon">
                    <input type="text" name="feed_Code11" lay-verify="required" placeholder="请输入申请单单号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs4 huanhang" >
                <div class="layui-input-inlineon">
                    <input type="text" class="layui-input" id="test-limit3" placeholder="请选择申请开始日期">
                    <div class="icons">

                    </div>
                </div>
            </div>
            <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs4">
                <div class="layui-input-inlineon">
                    <input type="text" class="layui-input" id="test-limit4" placeholder="请选择申请结束日期">
                    <div class="icons">

                    </div>
                </div>
            </div>
            <div class="layui-input-inline layui-col-lg3 layui-col-md3 layui-col-xs4">
                <div class="layui-input-inline" style="width:80%; margin-top: 10px;">
                    <select name="state" lay-verify="required" lay-search="">
                        <option value="">请选择审核状态</option>
                        <option value="0">审核通过</option>
                        <option value="-1">等待审核</option>

                    </select>
                </div>
            </div>
            <!--<div class="layui-input-inline layui-col-lg3 layui-col-md3">-->
            <!--<div class="layui-input-block" style="margin-left: 0;">-->
            <!--<select name="state" lay-filter="aihao">-->
            <!--<option value="" selected="">&#45;&#45;请选择审核状态&#45;&#45;</option>-->
            <!--<option value="0">审核通过</option>-->
            <!--<option value="-1">等待审核</option>-->
            <!--<option value="1">不通过</option>-->

            <!--</select>-->
            <!--</div>-->
            <!--</div>-->
            <div class="layui-col-lg3 layui-col-md3 layui-col-xs3 chaxun layui-col-space6" style="margin-top: 10px;">
                <button class="layui-btn" type="button" style="float: left;" onclick="query()">查询</button>
            </div>

        </div>
        <table id="demo" lay-filter="test"></table>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-sm layui-btn-danger shenhe quanxian" lay-event="edit" qx="api/matperson/matFeedVali.do">审核</a>
            <a class="layui-btn layui-btn-sm chakan quanxian" lay-event="detail" style="margin-left: 0;" qx="api/matperson/gcMatFeedSel.do">查看</a>
            <a class="layui-btn layui-btn-sm layui-btn-danger chongzhi quanxian" lay-event="reset1" style="margin-left: 0;" qx="api/matperson/resetFeedMaterial.do">重置</a>
        </script>
    </form>

    <div id="demo7"></div>
    <div class="mask">
        <div class="masksx">
            <div class="title"><span class="titleL">材料申请</span><span class="close">×</span></div>
            <div class="forms">
                <form class="layui-form addUser" method="post" action="">

                    <div class="layui-form-item">
                        <label class="layui-form-label">申请单单号<span class="maohao">：</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="feed_Code" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input" value="">
                            <input type="hidden" name="sup_Code" autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">供货时间:</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="supply_Time" lay-verify="required" id="gonghuoshijian"
                                   placeholder="yyyy-MM-dd">
                            <div class="icons">
                                <i class="layui-icon">&#xe637;</i>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">申请人<span class="maohao">：</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="feed_sqr" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">收货地址<span class="maohao">：</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="f_adr" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="material materialone">
                        <div class="layui-inline _materwarp">
                            <label class="material_C"><span class="addTo">+</span>材料名:</label>
                            <div class="layui-input-inline _mater">
                                <select name="modules" lay-verify="required" lay-search="" class="modules">
                                    <option value=""> </option>
                                </select>
                            </div>
                        </div>
                        <label class="_mater_lab">数量:</label>
                        <input type="number" name="username" lay-verify="required" placeholder="" autocomplete="off" class="layui-input _mater_input">
                        <button class="layui-btn layui-btn-xs  layui-btn-normal mater_btn" type="button"><i class="layui-icon">&#xe640;</i>  </button>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">备注<span class="maohao">：</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="addr2" autocomplete="off" placeholder="请输入" class="layui-input" value=""/>
                        </div>
                    </div>


                    <input type="hidden" name="cc_UUID" value="" />
                    <input type="hidden" name="sup_Code" value="" />


                    <div class="_submit">
                        <button class="layui-btn layui-btn-sm  tijiao" lay-submit lay-filter="_subm">提交</button>
                        <button class="layui-btn layui-btn-sm " type="reset">重置</button>
                    </div>

                </form>

            </div>

        </div>

    </div>
</div>

<script src="../../../resources/layui/layui.js" charset="utf-8"></script>
<script src="../../../resources/js/style.js"></script>
<script src="../../../resources/js/api.js"></script>
<script>

    function query() {
        layui.use(['form', 'layedit', 'laydate','table','element'], function() {
            var form = layui.form
                , table = layui.table;
            var pronName=$("[name='proName']").val();
            var begintime=$('#test-limit3').val();
            var endtime=$('#test-limit4').val();
            var state=$('[name="state"]').val();   //状态
            var feed_Code=$('[name="feed_Code11"]').val();        //申请单号
            //console.log(pronName)
            if(!AntiSqlValid(pronName)){
                if(lbq('api/matperson/gcMatFeedSel.do')){
                    API.cailiaoshenqingshenpi({
                        'type': 'a',
                        'proName': pronName,
                        'begintime': begintime,
                        'endtime': endtime,
                        'p': getCookie('yanzheng'),
                        'feed_Code': feed_Code,
                        'state': state
                    })
                }
            }else {
                layer.msg('请勿输入特殊符号');
            };
        })

    }
    layui.use(['form', 'layedit', 'laydate','table','element','laypage','flow'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate
            ,table=layui.table
            ,laypage=layui.laypage
            ,flow=layui.flow
            ,element=layui.element;
        jiazais();

        laydate.render({
            elem: '#gonghuoshijian' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#dates'
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#date1'
            ,type: 'datetime'
        });
        $(document).on('click','.mater_btn',function () {
            $(this).parent().remove();
        });
        $('.close').click(function () {     //遮罩层隐藏
            $('.mask').hide();
        });
        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //执行渲染
        if(lbq('api/matperson/gcMatFeedSel.do')!=-1){
            API.cailiaoshenqingshenpi({'type':'a','p':getCookie('yanzheng')});
        }
        //前后若干天可选，这里设置不能选过去的日期      最远可选1000天之后
        panduanshijiantow('#test-limit3','#test-limit4',1000,1000,'.layui-btn-normal');     //查询 开始结束时间判断
        dayintishi('.dayin');
        //监听工具条
        table.on('tool(test)', function(obj){ //注<span class="maohao">：</span>tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if(layEvent === 'edit'){ //编辑
                //do somehing
                //console.log(obj)
                sessionStorage.type='b';
                sessionStorage.MOVE_ID=obj.data.feed_Code;
                sessionStorage.danhao=obj.data.feed_Code;
                sessionStorage.f_adrs=obj.data.f_adr;
                location.href='./cailiaoshenpi.html';
            }else if(layEvent === 'detail'){ //查看
                //do something
                //console.log(obj)
                sessionStorage.type='c';
                sessionStorage.remark=obj.data.feed_Code;
                sessionStorage.f_adr=obj.data.f_adr;
                location.href='./cailaioshenqingDetail.html'
            }else if(layEvent==='shenqing'){
                //console.log(obj)
                $('.mask').show();
                $('.mask input').val('');
                $("[name='cc_UUID']").val(obj.data.cc_UUID);
                $("[name='sup_Code']").val(obj.data.compid);
            }else if(layEvent==="reset1"){
                layer.confirm('您确认要重置这个材料申请单吗?', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    ajaxs('/api/matperson/resetFeedMaterial.do','post',{'feedCode':obj.data.feed_Code,'p':getCookie('yanzheng')},function (data) {
                        if(data.code==0){
                            layer.msg(data.msg, {icon: 1});
                        }else{
                            layer.msg(data.msg, {icon: 2});
                        }
                    })
                });
            }
        });
        form.on('submit(_subm)',function (data) {
            //console.log(data.field)
            var cailiao='';
            $('.material').each(function () {
                cailiao+=$(this).children().children('._mater').children('.modules').val()+','+$(this).children('._mater_input').val()+'|';
            })
            cailiao=cailiao.substr(0,cailiao.length-1);
            //console.log(cailiao)
            data.field.sd=cailiao;
            data.field.p=getCookie('yanzheng');
            formAlertAjax('/api/ctteam/addMatFeed.do',data.field,'.tijiao');
            return false;
        });
        $("[name='feed_Code']").blur(function () {
            //console.log($(this).val()!= $("[name='namespan']").val())
            if($(this).val()== $("[name='namespan']").val()){
                return;
            }
            ajaxs('/api/public/cheName.do','get',{'type':3,'name':$(this).val()},function (data) {
                //console.log(data)
                if(data.code==0){
                    if(data.data=='1'){
                        layer.msg('申请单号已存在 请重新输入');
                        $('.tijiao').attr('disabled','true').addClass('layui-btn-disabled');//禁止提交按钮点击
                    }else{
                        layer.msg('申请单号可用');
                        $('.tijiao').removeAttr('disabled').removeClass('layui-btn-disabled');//禁止提交按钮点击
                    }
                }
            })
        });
        inputs();
        //材料添加
        $('.material_C').click(function () {
            var _dom=$(this).parents('.materialone').html();
            $('.materialone').after('<div class="material">'+_dom+'</div>');
            form.render();
        })
    })

</script>
</body>
</html>